<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\Option;
use App\Admin\Tool\GlobalConfigForm;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Card;
use Dcat\Admin\Widgets\Tab;

class OptionController extends AdminController
{
    function index(Content $content)
    {
        return $content
            ->title('全局参数设置')
            ->body(new Card(new GlobalConfigForm()));
    }

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new Option(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('option_name');
            $grid->column('option_value');

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new Option(), function (Show $show) {
            $show->field('id');
            $show->field('option_name');
            $show->field('option_value');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new Option(), function (Form $form) {

            $form->disableCreatingCheck();
            $form->disableHeader();
//            $form->list('breed','品种');
//            $form->list('health','健康情况');


        });




    }
}
